package com.zx.ishopping.utils;

/**
 * threadLocal
 * @author 祝鑫
 * @date 2025/6/22
 */
@SuppressWarnings("ALL")//忽略此代码中的所有警告
public class ThreadLocalUtil {
    //提供一个threadLocal对象
    private static final ThreadLocal THREAD_LOCAL = new ThreadLocal();

    //根据键获取线程中的值
    public static <T> T get(){
        return (T) THREAD_LOCAL.get();
    }

    //存储键值对
    public static void set(Object value){
        THREAD_LOCAL.set(value);
    }

    //清除ThreadLocal 防止内存泄漏
    public static void remove(){
        THREAD_LOCAL.remove();
    }
}
